#include "symbol.h"

// Predefined symbol all.
predefinedsymbol symbol::all = { "All" };
// Predefined symbol none.
predefinedsymbol symbol::none = { "None" };
// Predefined symbol automatic.
predefinedsymbol symbol::automatic = { "Automatic" };

// Default constructor that creates an empty symbol.
symbol::symbol() : referencevalue(nullptr) { }
// Copy constructor that creates an identical symbol.
symbol::symbol(const symbol &s) : referencevalue(s.referencevalue), userstring(s.userstring) { }
// Conversion constructor that creates a predefined symbol *ps.
symbol::symbol(const symbolreference &ps) : referencevalue(ps) { }
// Conversion constructor that creates a userdefined symbol with string us.
symbol::symbol(const string &us) : referencevalue(nullptr), userstring(us) { }
	
// This getter function returns the value.
symbol::type symbol::getType() const 
{ 
	if(referencevalue)
		return predefined;
	else if(!userstring.empty())
		return userdefined;
	else
		return empty;
}
// This getter function returns the reference of the predefined symbol (actually a pointer to a const).
symbolreference symbol::reference() const { return referencevalue; }
// This getter function returns the name of the symbol.
string symbol::name() const
{
	if(referencevalue)
		return *referencevalue;
	else if(!userstring.empty())
		return userstring;
	else
		return string();
}